import routes, { IRoute } from './routes'
import React from 'react'
import { BrowserRouter, Routes, Route } from 'react-router-dom'

const Router: React.FC = () => {
	const renderView = (routes: IRoute[]) => {
		return routes.map((v, i) => {
			return <Route path={ v.path } element={ <v.element></v.element> } key={i}>
				{ v.children && renderView(v.children) }
			</Route>
		})
	}
	return (
		<BrowserRouter>
			<Routes>
				{
					renderView(routes)
				}
			</Routes>
		</BrowserRouter>
	)
}


export default Router